package mof.gov.dmdc.view.backing.pagination;

import javax.faces.event.ActionEvent;

import oracle.adf.view.rich.component.rich.nav.RichCommandLink;

import org.apache.myfaces.trinidad.component.UIXIterator;

public class DmdcPagination {
    public DmdcPagination() {
        super();
    }
    
    private UIXIterator iterator;


    public void setIterator(UIXIterator iterator) {
        this.iterator = iterator;
    }

    public UIXIterator getIterator() {
        return iterator;
    }

    public boolean isBeforeDisabled() {
        return this.getIterator().getFirst() == 0;
    }
    
    public boolean isAfterDisabled() {
        return this.getIterator().getFirst() >= this.getIterator().getRowCount() - iterator.getRows();
    }
    
    public int getCurrentPageNumber() {
        return (this.getIterator().getFirst() / iterator.getRows()) + 1;
    }
    
    public void previousActionListener(ActionEvent actionEvent) {
        this.getIterator().setFirst(this.getIterator().getFirst() - iterator.getRows());
    }
    
    public void nextActionListener(ActionEvent actionEvent) {
        this.getIterator().setFirst(this.getIterator().getFirst() + iterator.getRows());
    }
}
